<?php

namespace Biz\model\wiki;


class WikiBasicLog extends \Doraemon\pockets\datebase\BaseDbModel
{
    const _CONFIG_FILE_ = 'db_store';

    const _CONFIG_SELECT_ = 'db_store';

    const _DATABASE_ = 'store';

    const _TABLE_NAME = 'wiki_basic_log';

    const OPERATE_TYPE_AUDIT = 1;//审核wiki

    const OPERATE_TYPE_BRAND_EDIT_AUDIT = 2;//品牌编辑待审核

    const OPERATE_BRAND_EDIT_AUDIT_VALUE = 'brand-edit-audit';//operate_value 编辑待审核固定值

    const STATE_NORMAL = 0;
    const STATE_PASS = 1;
    const STATE_DEL = 9;

    const OPERATE_TYPE_MAP = [
        self::OPERATE_TYPE_AUDIT => '审核wiki',
    ];


    public static function getByWhere($where, $select = '*')
    {
        return self::get($select, $where);
    }

    public static function selectByWhere($where, $select = '*')
    {
        $list = self::select($select, $where);
        return $list;
    }

    public static function selectCountWhere($where)
    {
        $count = self::count('id', $where);
        return $count;
    }

    public static function insertData($data)
    {
        if (!isset($data['addtime']) || !$data['addtime']) {
            $data['addtime'] = date('Y-m-d H:i:s');
        }
        if (!isset($data['edittime'])) {
            $data['edittime'] = date('Y-m-d H:i:s');
        }
        $ret = self::insert($data);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return self::id();
    }

    public static function updateData($data, $where)
    {
        if (!isset($data['edittime'])) {
            $data['edittime'] = date('Y-m-d H:i:s');
        }
        $ret = self::update($data, $where);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return true;
    }

}